package mashibing.class1;

import util.MathUtil;

/**
 * 冒泡排序
 *
 * @author yujiafan
 * @version 1.0.0
 * @create 2023-03-02
 */
public class Class1_2_BubbleSorted {

    public static void bubbleSort(int[] arr) {
        if (arr == null || arr.length <= 1) {
            return;
        }
        for (int i = arr.length - 1; i > 0; i--) {
            for (int j = 0; j < i; j++) {
                if (arr[j] > arr[j + 1]) {
                    MathUtil.swap(arr, j, j + 1);
                }
            }
        }
    }
}
